/* 公告管理部分接口 */
import request from '@/utils/request';

/**
 *获取列表
 *
 * @export POST
 * @param {string} organizationCode 发布人所在机构编码
 * @param {string} userName 当前用户
 * @param {string} searchName 搜索内容
 * @param {integer} pageNo 页码
 * @param {integer} pageSize 分页条数
 * @returns
 */
export async function getNoticeList({ organizationCode, userName, searchName, pageNo, pageSize }) {
    return request('/api/oa/v1/notice/getlist', {
        method: 'POST',
        data: { organizationCode, pageNo, pageSize, searchName, userName },
        encryption: false
    });
}

/**
 *获取公告详情
 *
 * @export GET
 * @param {string} noticeId 公告id
 * @returns
 */
export async function fetchNoticeDetail({ noticeId }) {
    return request(`/api/oa/v1/notice/getone/${noticeId}`, {
        method: 'GET',
        encryption: false
    });
}

/**
 *删除公告
 *
 * @export GET
 * @param {string} noticeId 公告id
 * @returns
 */
export async function delNotice({ noticeId }) {
    return request(`/api/oa/v1/notice/delete/${noticeId}`, {
        method: 'GET'
    });
}

/**
 * 修改公告
 *
 * @export POST
 * @param {string} id 公告id
 * @param {string} organizationCode 发布人所在机构编码
 * @param {string} recvOrganizationCode 通知接受机构
 * @param {string} title 公告标题
 * @param {string} briefContent 简短内容
 * @param {string} content 公告内容
 * @param {string} startTime 公告发布时间
 * @returns
 */
export async function updateNotice({
    id,
    organizationCode,
    recvOrganizationCode,
    title,
    briefContent,
    content,
    startTime,
    attachFile
}) {
    return request('/api/oa/v1/notice/update', {
        method: 'POST',
        data: { id, organizationCode, recvOrganizationCode, title, briefContent, content, startTime, attachFile },
        encryption: false
    });
}

/**
 *增加公告
 *
 * @export POST
 * @param {string} id 公告id
 * @param {string} organizationCode 发布人所在机构编码
 * @param {string} recvOrganizationCode 通知接受机构
 * @param {string} title 公告标题
 * @param {string} briefContent 简短内容
 * @param {string} content 公告内容
 * @param {string} startTime 公告发布时间
 * @returns
 */
export async function addNotice({
    organizationCode,
    recvOrganizationCode,
    title,
    briefContent,
    content,
    startTime,
    attachFile
}) {
    return request('/api/oa/v1/notice/saveorupdate', {
        method: 'POST',
        data: { organizationCode, recvOrganizationCode, title, briefContent, content, startTime, attachFile },
        encryption: false
    });
}

/**
 *获取公司树
 *
 * @export POST
 * @returns
 */
export async function companyTree(data) {
    // return request('/api/org/v1/functional/list', {
    return request('/api/uc/org/v2/list', {
        method: 'POST',
        data
    });
}
